
  <template>
  <div class="bf-commont-template">

    <!-- <div style="padding: 0 16px ;">
      <h3>员工花名册</h3>
      <p>该页面代码已经自动生成，按照普通码 表增删改查 为基础生成模板</p>
      <p>生成代码对应的 vue 文件路径：D:\Zmyitem\vue-element-admin\src\beneform4j\view\hr\employeemanage\employees\index.vue</p>
      <el-alert title="注意：表格内数据为模拟数据, 如果数据格式不对，请先进行格式转换。 模拟数据文件路径：src/mock/demo.js" type="warning"> </el-alert>
    </div> -->

    <div class="clearfix bf-top-button">
      <div class="float-l">
        <!-- <el-button @click="addWaitOnJob" type="primary">添加待入职</el-button> -->
        <el-button @click="addRoster" type="primary">添加员工</el-button>
        <el-button @click="exportRoster">导出</el-button>
      </div>
      <div class="float-r">
        <div class="float-l">
          <el-input
            placeholder="请输入员工姓名搜索"
            prefix-icon="el-icon-search"
            v-model="searchData"
            @keyup.enter.native="quickSearch"
          ></el-input>
        </div>
        <div class="float-l padding-l">
          <el-button @click="showSearch" type="primary">高级筛选</el-button>
          <!-- <el-button @click="orgFilter" type="primary">机构筛选</el-button> -->
        </div>
      </div>
    </div>

    <div class="margin-l margin-r tabs-content">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane :label="'全部'+ (tabs.count4Statusall?tabs.count4Statusall:0)" name="all">
          <bf-table
            :data="allListData"
            :setting="addRosterForm"
            :rowAction="rowActionAll"

            @pageChange = "pageChange"
            ref="table6"
          ></bf-table>
        </el-tab-pane>

        <el-tab-pane :label="'在职' + (tabs.count4Status9?tabs.count4Status9:0)" name="onJob">
          <bf-table
            :data="onJobData"
            :setting="addRosterForm"
            :rowAction="onJobAction"
            @pageChange = "pageChange"
            ref="table1"
          ></bf-table>
        </el-tab-pane>

        <el-tab-pane :label="'待入职'+ (tabs.count4Statusa?tabs.count4Statusa:0)" name="waitOnJob">
          <bf-table
            :data="waitOnJobData"
            :setting="waitOnJobSetting"
            :rowAction="waitOnJobAction"

            @pageChange = "pageChange"
            ref="table2"
          ></bf-table>
        </el-tab-pane>

        <el-tab-pane :label="'试用期'+ (tabs.count4Status0?tabs.count4Status0:0)" name="probation">
          <bf-table
            :data="probationData"
            :setting="shiYonForm"
            :rowAction="probationAction"

            @pageChange = "pageChange"
            ref="table3"
          ></bf-table>
        </el-tab-pane>

        <el-tab-pane :label="'待离职' + (tabs.count4Status8?tabs.count4Status8:0)" name="waitQuit">
          <bf-table
            :data="waitQuitData"
            :setting="addRosterForm"
            :rowAction="waitQuitAction"

            @pageChange = "pageChange"
            ref="table4"
          ></bf-table>
        </el-tab-pane>

        <el-tab-pane :label="'已离职'+ (tabs.count4Statusd?tabs.count4Statusd:0)" name="quit">
          <bf-table
            :data="quitData"
            :setting="addRosterForm"
            :rowAction="quitAction"

            @pageChange = "pageChange"
            ref="table5"
          ></bf-table>
        </el-tab-pane>



      </el-tabs>
    </div>
    <!-- 添加待入职 -->
    <!-- <bf-table-add :editForm ='addWaitOnjobForm' ref='addWaitOnJobFormRef' @formSubmit='addWaitOnjobSubmit'></bf-table-add> -->
    <!-- 添加员工 -->
    <bf-table-edit :title="'添加员工'" :rowNum="2" :width="800" :editRules="addRosterFormRules" :editForm ='addRosterForm2' ref='addRosterRef' @formSubmit='addRosterSubmit'></bf-table-edit>
    <!-- 高级搜索 -->
    <bf-table-search :editForm ='searchRosterForm' ref='searchRosterRef' @formSubmit='searchRosterSubmit'></bf-table-search>
    <!-- 试用期-办理转正 -->
    <bf-table-edit :title="'办理转正'" :rowNum="2" :width="800" :editForm ='convertFullRosterForm' :editRules="addRosterFormRules" ref='convertFullRosterRef' @formSubmit='convertFullRosterSubmit'></bf-table-edit>

    <!-- 人事异动 -->
    <bf-table-edit :title="'人事异动'" :rowNum="2" :width="800" :editRules="turnoverFormRules" :editForm ='changeRosterForm' ref='changeRosterRef' @formSubmit='changeRosterSubmit'></bf-table-edit>

    <!-- 在职-办理离职 -->
    <bf-table-edit :title="'办理离职'" :editRules="dealQuitFormRules" :editForm ='dealQuitForm' ref='onJobQuitRef' @formSubmit='onJobQuitForm'></bf-table-edit>

    <!-- 试用期-办理离职 -->
    <bf-table-edit :title="'办理离职'" :editRules="dealQuitFormRules" :editForm ='dealQuitForm' ref='dealQuitRef' @formSubmit='dealQuitSubmit'></bf-table-edit>

    <!-- 办理入职 -->
    <bf-table-edit :title="'办理入职'"  :rowNum="2" :width="800" :editRules="dealOnJobFormRules" :editForm ='dealOnJobForm' ref='dealOnJobRef' @formSubmit='dealOnJobSubmit'></bf-table-edit>
    <!-- 放弃入职 -->
    <bf-table-edit :title="'放弃入职'" :editRules="abandonJobFormRules" :editForm ='abandonJobForm' ref='abandonJobRef' @formSubmit='abandonJobSubmit'></bf-table-edit>

    <!-- 试用延期 -->
    <bf-table-edit :title="'试用延期'" :editRules="extendProbationRules" :editForm ='extendProbationForm' ref='extendProbationRef' @formSubmit='extendProbationSubmit'></bf-table-edit>

    <!-- 确认离职 -->
    <bf-table-edit :title="'确认离职'" :editRules="confirmQuitFormRules" :editForm ='confirmQuitForm' ref='confirmQuitRef' @formSubmit='confirmQuitSubmit'></bf-table-edit>
    <!-- 调整离职信息 -->
    <bf-table-edit :title="'调整离职信息'" :editRules="adjustQuitFormRules" :editForm ='adjustQuitForm' ref='adjustQuitRef' @formSubmit='adjustQuitSubmit'></bf-table-edit>
    <!-- 重新入职 -->
    <bf-table-edit  :title="'重新入职'" :rowNum="2" :width="800" :editRules="addRosterFormRules" :editForm ='reOnJobForm' ref='reOnJobRef' @formSubmit='reOnJobSubmit'></bf-table-edit>
    <!-- 撤销入职 -->
    <bf-table-edit :title="'撤销入职'" :editRules="revokeQuitFormRules" :editForm ='revokeQuitForm' ref='revokeQuitRef' @formSubmit='revokeQuitSubmit'></bf-table-edit>
    <!-- 调整入职信息 -->
    <bf-table-edit :editRules="addRosterFormRules" :title="'调整入职信息'" :rowNum="2" :width="800" :editForm ='adjustOnJobForm' ref='adjustOnJobRef' @formSubmit='adjustWaitJobSubmit'></bf-table-edit>
    <!-- 在职详情 -->
    <bf-table-detail :title="'详情'"  :rowNum="2" :width="800" :editForm ='addRosterForm' ref='onjobdetail'></bf-table-detail>
    <!-- 待入职详情 -->
    <bf-table-detail
      :title="'详情'"
      :rowNum="2"
      :width="800"
      :editForm ='waitOnJobSetting'
      ref='waitjobdetail'
    ></bf-table-detail>
    <!-- 试用期详情 -->
    <bf-table-detail :title="'详情'"  :rowNum="2" :width="800" :editForm ='proRosterForm' ref='onjobdetail2'></bf-table-detail>
  </div>
</template>

<script>

import { getAllEmpApi, getDealDelayList, getLeaveInfoApi, adjustWaitJobApi, reOnJobQuitApi, onJobQuitApi, revokeLeaveApi, adjustQuitApi, confirmLeaveApi, giveupLeaveApi, getEmployeesNumber, getEmployeesOnJob, conrrectApi, addRosterApi, turnoverApi, quitApi, dealOnJobApi, abandonJobApi, probationDelayApi } from './api.js'
import { delayListSetting, onJobSetting, waitOnJobSetting, probationSetting, waitQuitSetting, quitSetting } from './table.setting.js'
import { proRosterForm, addRosterForm2, shiYonForm, reOnJobForm, adjustOnJobForm, revokeQuitForm, adjustQuitForm, confirmQuitForm, extendProbationForm, abandonJobForm, addWaitOnjobForm, addRosterForm, searchRosterForm, convertFullRosterForm, changeRosterForm, dealQuitForm, dealOnJobForm } from './table.form.js'
import { revokeQuitFormRules, adjustQuitFormRules, confirmQuitFormRules, dealQuitFormRules, addRosterFormRules, turnoverFormRules, dealOnJobFormRules, abandonJobFormRules, extendProbationRules } from './table.rule'
export default {
  data() {
    return {
      proRosterForm: proRosterForm,
      delayListSetting: delayListSetting,
      activeName: 'onJob',
      tabs: {},
      searchData: '',
      leaveInfoData: {},
      userData: {
        list: [],
        total: 0
      },

      onJobSetting: onJobSetting,
      waitOnJobSetting: waitOnJobSetting,
      probationSetting: probationSetting,
      waitQuitSetting: waitQuitSetting,
      quitSetting: quitSetting,
      addWaitOnjobForm: addWaitOnjobForm,
      addRosterForm: addRosterForm,
      addRosterForm2: addRosterForm2,
      shiYonForm: shiYonForm,
      searchRosterForm: searchRosterForm,
      convertFullRosterForm: convertFullRosterForm,
      changeRosterForm: changeRosterForm,
      dealQuitForm: dealQuitForm,
      dealOnJobForm: dealOnJobForm,
      abandonJobForm: abandonJobForm,
      extendProbationForm: extendProbationForm,
      confirmQuitForm: confirmQuitForm,
      adjustQuitForm: adjustQuitForm,
      reOnJobForm: reOnJobForm,
      revokeQuitForm: revokeQuitForm,
      adjustOnJobForm: adjustOnJobForm,
      addRosterFormRules: addRosterFormRules,
      turnoverFormRules: turnoverFormRules,
      dealOnJobFormRules: dealOnJobFormRules,
      abandonJobFormRules: abandonJobFormRules,
      extendProbationRules: extendProbationRules,
      dealQuitFormRules: dealQuitFormRules,
      confirmQuitFormRules: confirmQuitFormRules,
      adjustQuitFormRules: adjustQuitFormRules,
      revokeQuitFormRules: revokeQuitFormRules,
      allListData: {},
      onJobData: { }, // 在职人员
      waitOnJobData: { }, // 待入职人员
      probationData: { }, // 试用期人员
      waitQuitData: { }, // 待离职人员
      quitData: { }, // 离职人员
      rowActionAll: [
        {
          label: '详情',
          click: (item) => {
            // this.$refs.table1.showDetail(item)
            if (!item.scope.row.employeeName) {
              item.scope.row.employeeName = item.scope.row.intvName
            }
            this.$refs.onjobdetail.show(item.scope)
          }
        },
        {
          label: '人事异动',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // this.turnovere(item)
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.turnovere(item)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '办理离职',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // this.$refs.dealQuitRef.show(item.scope)
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.onJobQuitRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },

        {
          label: '办理入职',
          hiddenStatus: (row) => {
            if (row.status == 'a') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.status === 'a') {
              item.scope.row.employeeName = item.scope.row.intvName
              this.$refs.dealOnJobRef.show(item.scope)
            } else {
              this.$message({
                message: '办理入职审批中，不可重复提交或者编辑',
                type: 'error'
              })
            }
          }
        },
        {
          label: '放弃入职',
          hiddenStatus: (row) => {
            if (row.status == 'a') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.status === 'a') {
              item.scope.row.remarks = ''
              this.$refs.abandonJobRef.show(item.scope)
            } else {
              this.$message({
                message: '办理入职审批中，不可重复提交或者编辑',
                type: 'error'
              })
            }
            // this.$refs.abandonJobRef.show(item.scope)
          }
        },
        {
          label: '调整入职信息',
          hiddenStatus: (row) => {
            if (row.status == 'a') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.status === 'a') {
              item.scope.row.targetOrgId = ''
              item.scope.row.targetPostLevel = ''
              item.scope.row.targetPost = ''
              this.$refs.adjustOnJobRef.show(item.scope)
            } else {
              this.$message({
                message: '办理入职审批中，不可重复提交或者编辑',
                type: 'error'
              })
            }
            // this.$refs.adjustOnJobRef.show(item.scope)
          }
        },
        {
          label: '办理转正',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.convertFullRosterRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '试用延期',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.extendProbationRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '确认离职',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '8' || row.employeeStatus === '6') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // this.$refs.confirmQuitRef.show(item.scope)
            if (item.scope.row.employeeStatus === '8' || item.scope.row.employeeStatus === '6') {
              getLeaveInfoApi(item.scope.row).then(response => {
                // console.log(response)
                if (response.success) {
                  this.leaveInfoData = response.data
                  this.$refs.confirmQuitRef.show(response.data)
                }
              })
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '放弃离职',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '8' || row.employeeStatus === '6') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            this.$confirm('放弃离职后员工状态将恢复为在职/试用期, 是否继续?', '提示', {
              cancelButtonText: '取消',
              confirmButtonText: '确定',
              type: 'warning'
            }).then(() => {
              // console.log(item)
              const params = {
                employeeNo: item.scope.row.employeeNo,
                employeeStatus: item.scope.row.employeeStatus
              }
              giveupLeaveApi(params).then(response => {
                if (response.success) {
                  this.$message({
                    message: '修改成功',
                    type: 'success'
                  })
                  this.getRostData({ page: 1 })
                }
              })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消操作'
              })
            })
          }
        },
        {
          label: '调整离职信息',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '8' || row.employeeStatus === '6') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // console.log(item)
            if (item.scope.row.employeeStatus === '8' || item.scope.row.employeeStatus === '6') {
              getLeaveInfoApi(item.scope.row).then(response => {
                // console.log(response)
                if (response.success) {
                  this.leaveInfoData = response.data
                  this.$refs.adjustQuitRef.show(response.data)
                  // this.$refs.confirmQuitRef.show(response.data)
                }
              })
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '重新入职',
          hiddenStatus: (row) => {
            if (row.employeeStatus === 'd') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // this.$refs.reOnJobRef.show(item.scope)
            item.scope.row.employeeStatus = '0'
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9' || item.scope.row.employeeStatus === 'd') {
              this.$refs.reOnJobRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '更多功能',
          hiddenStatus: (row) => {
            if (row.status === 'a') {
              return false
            } else {
              return true
            }
          },
          click: (item) => {
            this.gotoMoreInfo(item.scope.row.employeeNo)
          }
        }
      ],
      ruzhiAction: [
        {
          label: '详情',
          click: (item) => {
            // this.$refs.table1.showDetail(item)
            this.$refs.onjobdetail.show(item.scope)
          }
        }
      ],
      onJobAction: [
        {
          label: '详情',
          click: (item) => {
            // this.$refs.table1.showDetail(item)
            this.$refs.onjobdetail.show(item.scope)
          }
        },
        {
          label: '人事异动',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // this.turnovere(item)
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.turnovere(item)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '办理离职',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            // this.$refs.dealQuitRef.show(item.scope)
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.onJobQuitRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '更多功能',
          click: (item) => {
            this.gotoMoreInfo(item.scope.row.employeeNo)
          }
        }
      ],
      waitOnJobAction: [
        {
          label: '详情',
          click: (item) => {
            if (!item.scope.row.employeeName) {
              item.scope.row.employeeName = item.scope.row.intvName
            }
            this.$refs.waitjobdetail.show(item.scope)
          }
        },
        {
          label: '办理入职',
          hiddenStatus: (row) => {
            if (row.status == 'a') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.status === 'a') {
              item.scope.row.employeeName = item.scope.row.intvName
              this.$refs.dealOnJobRef.show(item.scope)
            } else {
              this.$message({
                message: '办理入职审批中，不可重复提交或者编辑',
                type: 'error'
              })
            }
          }
        },
        {
          label: '放弃入职',
          hiddenStatus: (row) => {
            if (row.status == 'a') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.status === 'a') {
              item.scope.row.remarks = ''
              this.$refs.abandonJobRef.show(item.scope)
            } else {
              this.$message({
                message: '办理入职审批中，不可重复提交或者编辑',
                type: 'error'
              })
            }
            // this.$refs.abandonJobRef.show(item.scope)
          }
        },
        {
          label: '调整入职信息',
          hiddenStatus: (row) => {
            if (row.status == 'a') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.status === 'a') {
              item.scope.row.targetOrgId = ''
              item.scope.row.targetPostLevel = ''
              item.scope.row.targetPost = ''
              this.$refs.adjustOnJobRef.show(item.scope)
            } else {
              this.$message({
                message: '办理入职审批中，不可重复提交或者编辑',
                type: 'error'
              })
            }
            // this.$refs.adjustOnJobRef.show(item.scope)
          }
        }
      ],
      probationAction: [
        {
          label: '详情',
          click: (item) => {
            // this.$refs.table3.showDetail(item)
            this.$refs.onjobdetail2.show(item.scope)
          }
        },
        {
          label: '办理转正',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.convertFullRosterRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '人事异动',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.turnovere(item)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '办理离职',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.dealQuitRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '试用延期',
          hiddenStatus: (row) => {
            if (row.employeeStatus === '0' || row.employeeStatus === '9') {
              return true
            } else {
              return false
            }
          },
          click: (item) => {
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
              this.$refs.extendProbationRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '更多功能',
          click: (item) => {
            this.gotoMoreInfo(item.scope.row.employeeNo)
          }
        }
      ],
      waitQuitAction: [
        {
          label: '详情',
          click: (item) => {
            // this.$refs.table4.showDetail(item)
            this.$refs.onjobdetail.show(item.scope)
          }
        },
        {
          label: '确认离职',
          click: (item) => {
            // this.$refs.confirmQuitRef.show(item.scope)
            if (item.scope.row.employeeStatus === '8' || item.scope.row.employeeStatus === '6') {
              getLeaveInfoApi(item.scope.row).then(response => {
                // console.log(response)
                if (response.success) {
                  this.leaveInfoData = response.data
                  this.$refs.confirmQuitRef.show(response.data)
                }
              })
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '放弃离职',
          click: (item) => {
            this.$confirm('放弃离职后员工状态将恢复为在职/试用期, 是否继续?', '提示', {
              cancelButtonText: '取消',
              confirmButtonText: '确定',
              type: 'warning'
            }).then(() => {
              // console.log(item)
              const params = {
                employeeNo: item.scope.row.employeeNo,
                employeeStatus: item.scope.row.employeeStatus
              }
              giveupLeaveApi(params).then(response => {
                if (response.success) {
                  this.$message({
                    message: '修改成功',
                    type: 'success'
                  })
                  this.getRostData({ page: 1 })
                }
              })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消操作'
              })
            })
          }
        },
        {
          label: '调整离职信息',
          click: (item) => {
            // console.log(item)
            if (item.scope.row.employeeStatus === '8' || item.scope.row.employeeStatus === '6') {
              getLeaveInfoApi(item.scope.row).then(response => {
                // console.log(response)
                if (response.success) {
                  this.leaveInfoData = response.data
                  this.$refs.adjustQuitRef.show(response.data)
                  // this.$refs.confirmQuitRef.show(response.data)
                }
              })
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        {
          label: '更多功能',
          click: (item) => {
            this.gotoMoreInfo(item.scope.row.employeeNo)
          }
        }
      ],
      quitAction: [
        {
          label: '详情',
          click: (item) => {
            // this.$refs.table5.showDetail(item)
            this.$refs.onjobdetail.show(item.scope)
          }
        },
        {
          label: '重新入职',
          click: (item) => {
            // this.$refs.reOnJobRef.show(item.scope)
            item.scope.row.employeeStatus = '0'
            if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9' || item.scope.row.employeeStatus === 'd') {
              this.$refs.reOnJobRef.show(item.scope)
            } else {
              this.dealStatus(item.scope.row.employeeStatus)
            }
          }
        },
        // {
        //   label: '撤销离职',
        //   click: (item) => {
        //     if (item.scope.row.employeeStatus === '0' || item.scope.row.employeeStatus === '9') {
        //       this.$refs.revokeQuitRef.show({
        //         employeeNo: item.scope.row.employeeNo
        //       })
        //     } else {
        //       this.dealStatus(item.scope.row.employeeStatus)
        //     }
        //   }
        // },
        {
          label: '更多功能',
          click: (item) => {
            this.gotoMoreInfo(item.scope.row.employeeNo)
          }
        }
      ],
      searchParams: { // 搜索条件
        page: 1
      },
      ruzhiNum: 0,
      ruzhiData: []
    }
  },
  mounted: function() {
    //  let arrTmp = this.waitQuitAction.concat(this.probationAction).concat(this.waitOnJobAction).concat(this.onJobAction)
    /**
     *  页面初始化，获取再职员工信息
     */
    this.getRostData({ page: 1 })
    /**
     * 获取员工状态统计信息
     */
    this.getRosterDetail()
  },
  methods: {
    getLeaveInfo(params) {
      getLeaveInfoApi(params).then(response => {
        if (response.success) {
          this.leaveInfoData = response.data
        }
      })
    },
    dealStatus(status) {
      if (status === '1'){
        this.$message({
          message: '转正审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === '2'){
        this.$message({
          message: '试用期异动中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === '3'){
        this.$message({
          message: '在职异动中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === '4'){
        this.$message({
          message: '试用延期审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === '5'){
        this.$message({
          message: '试用离职审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === '7'){
        this.$message({
          message: '正式离职审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === 'w'){
        this.$message({
          message: '添加试用员工审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === 'x'){
        this.$message({
          message: '添加正式员工审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === 'y'){
        this.$message({
          message: '办理试用入职审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
      if (status === 'z'){
        this.$message({
          message: '办理正式入职审批中，无法进行其他申请操作，请等待审批完成后重试',
          type: 'error'
        })
        return
      }
    },
    onJobQuitForm(form) {
      /**
       * 正式员工办理离职
       */
      // console.log(form)
      // return
      form.status = 1
      onJobQuitApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.onJobQuitRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    turnovere(item){
      /**
       * 人事异动
       */
      // console.log(item)
      item.scope.row.originalOrgId = item.scope.row.orgId // 部门
      item.scope.row.targetOrgId = ''
      item.scope.row.originalPost = item.scope.row.position // 岗位
      item.scope.row.targetPost = ''
      item.scope.row.originalPostLevel = item.scope.row.postLevel // 职级
      item.scope.row.targetPostLevel = ''
      item.scope.row.originalWorkAddr = item.scope.row.workAddree // 工作地址
      item.scope.row.targetWorkAddr = item.scope.row.workAddree
      item.scope.row.originalCompany = item.scope.row.constractCompany // 合同公司
      item.scope.row.targetCompany = item.scope.row.constractCompany
      this.$refs.changeRosterRef.show(item.scope)
    },
    gotoMoreInfo(id){
      this.$router.push(
        {
          path: '/0302/030204',
          query: { id: id }
        }
      )
    },
    getRosterDetail() {
      /**
       * 查询员工状态统计
       */
      getEmployeesNumber().then((response) => {
        // console.log(response)
        if (response.data) {
          this.tabs = response.data
        } else {
          this.tabs = {}
        }
      })
    },
    getOnJob(params) {
      /**
       * 获取在职
       * employeeStatus: '9',
       */
      getEmployeesOnJob(params).then((response) => {
        this.onJobData = response
      })
    },
    getWaitOnJob(params) {
      /**
       * 获取待入职
       */
      getEmployeesOnJob(params).then((response) => {
        this.waitOnJobData = response
      })
    },
    getProbation(params) {
      /**
       * 获取试用期人员
       */

      getEmployeesOnJob(params).then((response) => {
        this.probationData = response
      })
    },
    getWaitQuit(params) {
      /**
       * 获取待离职人员
       */

      getEmployeesOnJob(params).then((response) => {
        this.waitQuitData = response
      })
    },
    getQuit(params) {
      /**
       * 获取离职人员
       */

      getEmployeesOnJob(params).then((response) => {
        this.quitData = response
      })
    },
    pageChange(pageObj) {
      // console.log(pageObj)
      // this.getRostData(this.activeName, pageObj.page, pageObj.pageSize)
      this.searchParams.page = pageObj.page
      this.searchParams.pageSize = pageObj.pageSize

      this.getRostData()
    },
    showSearch() {
      this.$refs.searchRosterRef.show()
    },
    quickSearch() {
      /**
       * 快速搜索
       */
      this.searchParams.page = 1
      this.searchParams.employeeName = this.searchData
      this.getRostData()
    },
    getAllList(params) {
      getAllEmpApi(params).then((response) => {
        this.allListData = response
      })
    },
    getRostData() {
      const params = this.searchParams

      this.hideen()
      this.getRosterDetail()
      // 获取入职申请
      // getDealDelayList(params).then(response => {
      //   if (response.list) {
      //     this.ruzhiData = response
      //     this.ruzhiNum = response.page.total
      //   }
      // })
      if (this.activeName === 'all') {
        params.employeeStatus = null
        this.getAllList(params)
        return
      }
      if (this.activeName === 'onJob') {
        // employeeStatus: '9',
        params.employeeStatus = '9'
        this.getOnJob(params)
        return
      }
      if (this.activeName === 'waitOnJob') {
        // employeeStatus: 'a',
        if (params.employeeName) {
          params.intvName = params.employeeName
          delete params.employeeName
        } else {
          delete params.intvName
        }
        delete params.employeeNo

        params.employeeStatus = 'a'
        this.getWaitOnJob(params)
        return
      }
      if (this.activeName === 'probation') {
        // employeeStatus: '0'
        params.employeeStatus = '0'
        this.getProbation(params)
        return
      }
      if (this.activeName === 'waitQuit') {
        // employeeStatus: '8',
        params.employeeStatus = '8'
        this.getWaitQuit(params)
        return
      }
      if (this.activeName === 'quit') {
        // employeeStatus: 'd',
        params.employeeStatus = 'd'
        this.getQuit(params)
        return
      }
    },
    handleClick(tab, event) {
      // const status = tab.name
      this.searchParams.page = 1
      this.getRostData()
    },
    exportRoster() {
      /**
       * 导出功能
       */
      this.$message({
        message: '导出功能正在开发中，敬请期待。',
        type: 'warning'
      })
    },
    orgFilter() {
      /**
       * 机构筛选功能
       */
      this.$message({
        message: '机构筛选功能正在开发中，敬请期待。',
        type: 'warning'
      })
    },
    addWaitOnjobSubmit(form) {
      /**
       * 提交待入职数据
       */
      // console.log(form)
    },
    addWaitOnJob() {
      this.$refs.addWaitOnJobFormRef.show()
    },
    addRosterSubmit(form) {
      /**
       * 提交添加员工数据
       */
      // 通过试用期计算转正日期
      // console.log(form)
      // return
      // if (form.conrrectionDate) {
      //   if (form.conrrectionDate === '0') {
      //     form.conrrectionDate = form.entryDate
      //     form.planCorrectionDate =  form.entryDate
      //   } else {
      //     let date = getConrrectionDate(form.entryDate, form.conrrectionDate)
      //     // console.log(date)
      //     if (form.employeeStatus === '0') {
      //       form.planCorrectionDate = date
      //     }
      //     if (form.employeeStatus === '9') {
      //       form.conrrectionDate = date
      //     }
      //   }
      // }
      // function getConrrectionDate(date, monthNumber) {
      //   let m = Number(monthNumber)
      //   if (m) {
      //     // console.log(date, m)
      //     let dateArr = date.split('-')
      //     let year = Number(dateArr[0])
      //     let month = Number(dateArr[1])
      //     if (month + m > 12) {
      //       month = month + m - 12
      //       year = year + 1
      //     } else {
      //       month = month + m
      //     }
      //     if (month < 10) {
      //       month = '0' + month
      //     }
      //     return '' + year + '-' + month + '-' + dateArr[2]
      //   }
      // }
      // console.log(form.employeeStatus)
      // return
      // if (form.employeeStatus === '0') {
      //   form.planCorrectionDate = form.entryDate
      // }
      // if (form.employeeStatus === '9') {
      //   form.conrrectionDate = form.entryDate
      // }

      addRosterApi(form).then((response) => {
        // console.log(response)
        if (response.success) {
          this.$message({
            message: '添加员工成功!',
            type: 'success'
          })
          this.$refs.addRosterRef.hidden()
          this.activeName = 'onJob'
          this.getRostData()
          this.getRosterDetail()
        }
      })
    },
    hideen() {
      this.$refs.searchRosterRef.hidden()
    },
    addRoster() {
      addRosterForm.forEach(v => {
        if (v.field == 'position') {
          v.options = []
        }
        if (v.field == 'postLevel') {
          v.options = []
        }
      })
      this.$refs.addRosterRef.show({
        postLevel: '',
        position: ''
      })
    },
    searchRosterSubmit(form) {
      /**
       * 高级搜索
       */
      this.searchParams.page = 1
      this.searchParams.employeeName = form.employeeName
      this.searchParams.employeeNo = form.employeeNo
      this.searchParams.orgId = form.orgId

      this.getRostData()
    },
    convertFullRosterSubmit(form) {
      /**
       * 办理转正
       */
      form.status = 1
      conrrectApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.convertFullRosterRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    adjustWaitJobSubmit(form) {
      // console.log(form)
      form.orgId = form.targetOrgId
      form.position = form.targetPost
      form.postLevel = form.targetPostLevel
      adjustWaitJobApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.adjustOnJobRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    changeRosterSubmit(form) {
      /**
       * 提交人事异动信息
       */
      // console.log(form)
      const params = {}
      params.status = 1
      params.turnoverType = form.turnoverType
      params.turnoverType = form.turnoverType
      params.originalOrgId = form.originalOrgId
      params.targetOrgId = form.targetOrgId
      params.originalPost = form.originalPost
      params.targetPost = form.targetPost
      params.originalPostLevel = form.originalPostLevel
      params.targetPostLevel = form.targetPostLevel
      params.originalWorkAddr = form.originalWorkAddr
      params.targetWorkAddr = form.targetWorkAddr
      params.originalCompany = form.originalCompany
      params.targetCompany = form.targetCompany
      params.effectDate = form.effectDate
      params.turnoverCause = form.turnoverCause
      params.remarks = form.remarks
      params.employeeNo = form.employeeNo
      params.employeeStatus = form.employeeStatus
      turnoverApi(params , params.employeeStatus).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.changeRosterRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    dealQuitSubmit(form) {
      /**
       * 办理离职
       */
      const params = {}
      params.status = 1
      params.employeeNo = form.employeeNo
      params.leaveApplyDate = form.leaveApplyDate
      params.lastWorkDate = form.lastWorkDate
      params.isSalarySettled = form.isSalarySettled
      params.salarySettledDate = form.salarySettledDate
      params.leaveReason = form.leaveReason
      params.remarks = form.remarks
      // console.log(params)
      quitApi(params).then(response => {
        if (response.success) {
          this.$message({
            message: '办理离职成功',
            type: 'success'
          })
          this.$refs.dealQuitRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    dealOnJobSubmit(form) {
      /**
       * 提交入职信息
       */
      // const params = {
      //   employeeNo: form.employeeNo,
      //   employeeName: form.employeeName,
      //   sex: form.sex,
      //   mobile: form.mobile,
      //   companyEmail: form.companyEmail,
      //   idType: form.idType,
      //   idNo: form.idNo,
      //   orgId: form.orgId,
      //   position: form.position,
      //   postLevel: form.postLevel,
      //   entryDate: form.entryDate,
      //   conrrectionDate: form.conrrectionDate,
      //   employeeStatus: form.employeeStatus,
      //   constractCompany: form.constractCompany,
      //   workAddree: form.workAddree,
      //   workNature: form.workNature,
      //   recruitmentChannel: form.recruitmentChannel,
      //   refereeMan: form.refereeMan,
      //   intvId: form.intvId,
      // }
      // console.log(params)
      dealOnJobApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.dealOnJobRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    abandonJobSubmit(form) {
      /**
       * 提交放弃入职信息
       */
      // console.log(form)
      const params = {
        intvId: form.intvId,
        remarks: form.remarks
      }
      abandonJobApi(params).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.abandonJobRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    extendProbationSubmit(form) {
      /**
       * 提交延长试用期信息
       */
      // console.log(form)
      // const params = {
      //   status: '1',
      //   employeeNo: form.employeeNo,
      //   planCorrectionDate: form.planCorrectionDate,
      //   delayCorrectionDate: form.delayCorrectionDate,
      //   delayApplyDate: form.delayApplyDate,
      //   delayReason: form.delayReason
      // }
      form.status = '1'
      // console.log(params)
      probationDelayApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.extendProbationRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    confirmQuitSubmit(form) {
      /**
       * 提交确认离职信息
       */
      // console.log(form)
      const params = {
        leaveApplyDate: form.leaveApplyDate,
        lastWorkDate: form.lastWorkDate,
        isSalarySettled: form.isSalarySettled,
        salarySettledDate: form.salarySettledDate,
        leaveReason: form.leaveReason,
        remarks: form.remarks,
        employeeNo: form.employeeNo
      }
      // console.log(params)
      confirmLeaveApi(params).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.confirmQuitRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    adjustQuitSubmit(form) {
      /**
       * 提交调整离职信息
       */
      // console.log(form)
      // return
      // const params = {
      //   employeeNo: form.employeeNo,
      //   leaveApplyDate: form.leaveApplyDate,
      //   lastWorkDate: form.lastWorkDate,
      //   isSalarySettled: form.isSalarySettled,
      //   salarySettledDate: form.salarySettledDate,
      //   leaveReason: form.leaveReason,
      //   remarks: form.remarks
      // }
      adjustQuitApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.adjustQuitRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    reOnJobSubmit(form) {
      /**
       * 提交重新入职信息
       */
      // console.log(form)
      reOnJobQuitApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.reOnJobRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    },
    revokeQuitSubmit(form) {
      /**
       * 提交撤销离职信息
       */
      // console.log(form)
      revokeLeaveApi(form).then(response => {
        if (response.success) {
          this.$message({
            message: '修改成功',
            type: 'success'
          })
          this.$refs.revokeQuitRef.hidden()
          this.getRostData({ page: 1 })
        }
      })
    }
  }
}
</script>

<style scoped>

.tabs-content >>> .table{
  padding: 0;
}
</style>
